﻿#include <iostream>
using namespace std;
//数组和指针
int main()
{

	int arr[5] = { 2,5,76,4,6 };
	cout << "arr[0]" << arr[0] << endl;
	cout << "arr[1]" << arr[1] << endl;
	cout << "arr[2]" << arr[2] << endl;
	cout << "arr[3]" << arr[3] << endl;
	cout << "arr[4]" << arr[4] << endl;

	int* p = arr;
	cout << "p[0]" << p[0] << endl;
	cout << "p[1]" << p[1] << endl;
	cout << "p[2]" << p[2] << endl;
	cout << "p[3]" << p[3] << endl;
	cout << "p[4]" << p[4] << endl;
	//arr++;报错数组名是常量不可修改
	cout << "*(p + 0)" << *(p + 0) << endl;
	cout << "*(p + 1)" << *(p + 1) << endl;
	cout << "*(p + 2)" << *(p + 2) << endl;
	cout << "*(p + 3)" << *(p + 3) << endl;
	cout << "*(p + 4)" << *(p + 4) << endl;

	cout << "*(arr + 0)" << *(arr + 0) << endl;
	cout << "*(arr + 1)" << *(arr + 1) << endl;
	cout << "*(arr + 2)" << *(arr + 2) << endl;
	cout << "*(arr + 3)" << *(arr + 3) << endl;
	cout << "*(arr + 4)" << *(arr + 4) << endl;
}
